package com.guangyunl.assignment;

public class Demo01Assignment {
    public static void main(String[] args) {
        System.out.println("i += 2;");
        System.out.println("==================");
        int i = 10;
        i += 2; //可以看作 i = i + 2;
        System.out.println("i = " + i);
        // i = 12
        System.out.println("==================");

//    += :
        System.out.println("+= :");
        int i1 = 10;
        i1 += 2; // -> i1 = i1 + 2;
        System.out.println( "i1 = " + i1 );
        // i1 = 12
        System.out.println("==================");

//    -= :
        System.out.println("-= :");
        int i2 = 10;
        i2 -= 2; // -> i2 = i2 - 2;
        System.out.println( "i2 = " + i2 );
        // i2 = 8
        System.out.println("==================");

//    *= :
        System.out.println("*= :");
        int i3 = 10;
        i3 *= 2; // -> i3 = i3 * 2;
        System.out.println( "i3 = " + i3 );
        // i3 = 20
        System.out.println("==================");

//    /= :
        System.out.println("/= :");
        int i4 = 10;
        i4 /= 2; // -> i4 = i4 / 2;
        System.out.println( "i4 = " + i4 );
        // i4 = 5
        System.out.println("==================");

//    %= :
        System.out.println("%= :");
        int i5 = 10;
        i5 %= 2; // -> i5 = i5 % 2;
        System.out.println( "i5 = " + i5 );
        // i5 = 0
        System.out.println("==================");


        System.out.println("==================");
        // 注意: byte short 遇到复合赋值运算符，jvm会自动转型
        byte b = 10;
//         b = (byte)(b + 1);
        b += 1; // b = b + 1;
        System.out.println("b = " + b);
        System.out.println("==================");

    }
}
